Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit contended paths to physical cores not logical cores #7132

Merged
merged 3 commits into from
Jun 4, 2024

Conversation

benaadams
Copy link
Member

Changes

  • Use physical cores rather than logical cores as the degree of parallisation to reduce contention

Types of changes

What types of changes does your code introduce?

  • Optimization

Testing

Requires testing

  • No

@benaadams benaadams requested a review from LukaszRozmej June 4, 2024 02:11
@benaadams benaadams changed the title Prewarmer limit contended path to physical cores not logical cores Prewarmer: limit contended path to physical cores not logical cores Jun 4, 2024
@benaadams benaadams requested a review from asdacap June 4, 2024 02:18
@benaadams benaadams changed the title Prewarmer: limit contended path to physical cores not logical cores Limit contended paths to physical cores not logical cores Jun 4, 2024
@@ -54,7 +55,7 @@ private void PreWarmCachesParallel(Block suggestedBlock, Hash256 parentStateRoot

try
{
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = Math.Max(1, Environment.ProcessorCount - 2), CancellationToken = cancellationToken };
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = Math.Max(1, RuntimeInformation.PhysicalCoreCount - 2), CancellationToken = cancellationToken };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make this one specifically configurable.

@LukaszRozmej
Copy link
Member

Is it helpful in any way? Logical Cores are most useful when thread is waiting for I/O, which should happen here.

@benaadams
Copy link
Member Author

Is it helpful in any way? Logical Cores are most useful when thread is waiting for I/O, which should happen here.

Not if your I/O has lock contention; then are just increasing the wall clock time with more contention

image

@benaadams benaadams merged commit 3d637e2 into master Jun 4, 2024
68 checks passed
@benaadams benaadams deleted the physical-cores branch June 4, 2024 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants